<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>公告信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	
		//CKEDITOR.replace( 'content' );
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				rules:{          
					title:{
						titleCheckNull:true,
						titleLengthMin:true,
						titleLengthMax:true,
						titleContentCheck:true
					} 
	            },
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		jQuery.validator.addMethod("titleCheckNull", function(value,element, param) { 
			if(value==null){
				return false;
			} else{
				if(value==""){
					return false;
				}else{
					return true;
				}
            }
        }, $.validator.format("请输入公告标题")); 
		jQuery.validator.addMethod("titleLengthMin", function(value,element, param) { 
			if(value.length<4){
				return false;
			} else{
				return true;
            }
        }, $.validator.format("请输入4-30个字符，以汉字或字母开头，可带数字")); 
		jQuery.validator.addMethod("titleLengthMax", function(value,element, param) { 
			if(value.length>30){
				return false;
			} else{
				return true;
            }
        }, $.validator.format("请输入4-30个字符，以汉字或字母开头，可带数字")); 
		jQuery.validator.addMethod("titleContentCheck", function(value,element, param) { 
			var tel = /^[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5]*$/;  
		 	return this.optional(element) || (tel.test(value));  
        }, $.validator.format("请输入4-30个字符，以汉字或字母开头，可带数字")); 
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/sys/system/announcement/">公告信息列表</a></li>
		<li class="active"><a href="${ctx}/sys/system/announcement/form?id=${announcement.id}">公告信息<shiro:hasPermission name="sys:announcement:edit">${not empty announcement.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:announcement:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="announcement" action="${ctx}/sys/system/announcement/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<div style="display:none;">
			<sys:message content="${message}"/>	
		</div>	
		<div class="control-group">
			<label class="control-label">公告标题：</label>
			<div class="controls">
				<form:input path="title"  class="input-xlarge"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">公告分类：</label>
			<div class="controls">
				<form:select id="announcementGroupId" path="announcementGroupId" class="input-medium required">
					<form:option value="" label="请选择"/>
				    <form:options items="${agList}" htmlEscape="false" itemValue="id" itemLabel="title"/>
			    </form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
			
		<div class="control-group">
			<label class="control-label">内容：</label>
			<div class="controls">
				<form:textarea path="content" id="content" htmlEscape="false" rows="4" class="input-xxlarge "/>
			</div>
		</div>
		<script type="text/javascript" >
	         // Replace the <textarea id="editor1"> with a CKEditor
	         // instance, using default configuration.
	          CKEDITOR.replace( 'content' ,{
            		filebrowserImageUploadUrl : "${ctx}/sys/file/uploadImage"
              });
        </script>
		<div class="form-actions">
			<shiro:hasPermission name="sys:announcement:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>